class User < ActiveRecord::Base
  validates_presence_of :username
  validates_presence_of :password
  validates_length_of :password, :within => 3..20

  def User.authenticate(username,password)
    u = find_by_username(username)
    u && u.password == password ? u : nil
    return u
  end
end
